// $codepro.audit.disable
package edu.gatech.team404.junit;

import edu.gatech.team404.Account;
import edu.gatech.team404.AccountType;
import edu.gatech.team404.Course;
import edu.gatech.team404.dal.AccountDAL;
import edu.gatech.team404.dal.CourseDAL;
import edu.gatech.team404.dal.IDatabase;
import junit.framework.TestCase;

/**
 * Run this test case to setup the database. Beware, database will be reset upon 
 * running this test case. Three account will be created: admin, instructor, and student,
 * with username equals to password. One course will be created, CS 1337. This process
 * may take sometime if the size of database is big.
 * 
 * @author Michael Dandy
 * @version 1.0
 */
public class DatabaseSetupTest extends TestCase
{
	AccountDAL aDal;
	CourseDAL cDal;
	
	Account admin;
	Account instructor;
	Account student;
	
	Course course = new Course ("CS 1337", "This is a test course.", "instructor");
	
	protected void setUp() throws Exception {
		super.setUp();
		aDal = new AccountDAL();
		cDal = new CourseDAL();
		
		admin = new Account ("admin", "admin", "Administrator", "admin@gatech.edu", AccountType.ADMIN);
		instructor = new Account ("instructor", "instructor", "Instructor", "instructor@gatech.edu", AccountType.INSTRUCTOR);
		student = new Account ("student", "student", "Student", "student@gatech.edu", AccountType.STUDENT);
	}
	
	public void  testResetDatabase() {
		IDatabase database = new IDatabase();
		assertTrue (database.resetDatabase());
	}
	
	public void testAccountSetup() {
		assertTrue (aDal.addAccount(admin));
		assertTrue (aDal.addAccount(instructor));
		assertTrue (aDal.addAccount(student));
	}
	
	public void testCourseSetup() {
		assertTrue (cDal.createCourse(course));
	}
}